package cn.com.zal.cgweb.pojo;

import cn.com.zal.cgweb.common.utils.TcProductUtil;
import cn.com.zal.cgweb.common.utils.UserUtil;

/**
 * TcCart entity. @author MyEclipse Persistence Tools
 */

public class TcCart implements java.io.Serializable {

	// Fields

	private TcCartId id;
	private Long quantity;
	
	// Constructors

	/** default constructor */
	public TcCart() {
	}

	/** full constructor */
	public TcCart(TcCartId id, Long quantity) {
		this.id = id;
		this.quantity = quantity;
	}

	// Property accessors

	public TcCartId getId() {
		return this.id;
	}

	public void setId(TcCartId id) {
		this.id = id;
	}

	public Long getQuantity() {
		return this.quantity;
	}

	public void setQuantity(Long quantity) {
		this.quantity = quantity;
	}
	
	
	public TcProduct getTcProduct(){
		return TcProductUtil.aTcProductDAO.findById(this.id.getProductId());
	}
	public TcUser getTcUser() throws Exception{
		return UserUtil.getUser(this.id.getUserId());
	}
	public double getXiaojie() throws Exception{
		return this.getTcProduct().getPrice()*this.quantity;
	}
	

}